#ifndef ADS7844_H
#define ADS7844_H

/// Definitions
// ADC Channels
#define IMU_yaw		0
#define IMU_roll	1
#define IMU_pitch	2
#define IMU_temp	3
#define IMU_accX	4
#define IMU_accY	5
#define IMU_accZ	6
#define IMU_dps		7

// ADC : Voltage reference 3.3v / 12bits(4096 steps) => 0.8mV/ADC step
// ADXL335 Sensitivity(from datasheet) => 330mV/g, 0.8mV/ADC step => 330/0.8 = 412
// Tested value : 418
#define GRAVITY 418						//this equivalent to 1G in the raw data coming from the accelerometer 
#define Accel_Scale(x) x*(GRAVITY/9.81)	//Scaling the raw data of the accel to actual acceleration in meters for seconds square

// We use Serial Port 2 in SPI Mode
#define ADC_DATAOUT     51    // MOSI
#define ADC_DATAIN      50    // MISO
#define ADC_SPICLOCK    52    // SCK
#define ADC_CHIP_SELECT 33    // PC4   9 // PH6  Puerto:0x08 Bit mask : 0x40

#include <inttypes.h>

class ADS7844
{
  private:

  public:
	ADS7844();  // Constructor
	void Init();
	void Update();
	int Ch(uint8_t ch);
	void calibrateACC();
	void calibrateGYRO();
	float Sensor[8];
	float Offset[8];
	float Scale[8];
	long lastUpdate();
};

#endif
